﻿/// ****************************************************************************
/// Author:	        Robin Zhu
/// Create Date:	2012-5-4
/// Purpose: 		权限审核服务的WCF服务端实现
/// ****************************************************************************
/// Modify By		Date			Remark
/// ****************************************************************************

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RB.Web.Security.Rdb;

namespace RB.Web.Security.Wcf
{
    /// <summary>
    /// 权限审核服务的WCF服务端实现
    /// </summary>
    public class AuthorizeService : IAuthorizeService
    {
        public bool Authorize(string appCode, string ticket, string pathAndQuery, string httpMethod)
        {
            DbAuthorizeService service = new DbAuthorizeService();
            return service.Authorize(appCode, ticket, pathAndQuery, httpMethod);
        }

        public bool IsAllowed(string appCode, Guid userId, string path, string httpMethod)
        {
            DbAuthorizeService service = new DbAuthorizeService();
            return service.IsAllowed(appCode, userId, path, httpMethod);
        }


        public AppMenu[] GetAppMenus(string appCode, Guid userId)
        {
            DbAuthorizeService service = new DbAuthorizeService();
            return service.GetAppMenus(appCode, userId);
        }




        public string[] GetPermissionCodesByTicket(string appCode, string ticket)
        {
            DbAuthorizeService service = new DbAuthorizeService();
            return service.GetPermissionCodesByTicket(appCode, ticket);
        }

        public Permission[] GetAllPermissions(string appCode)
        {
            DbAuthorizeService service = new DbAuthorizeService();
            return service.GetAllPermissions(appCode);
        }


        public void LogAction(string appCode, string ticket, string permCode, string pathAndQuery, bool authorized, string ipAddress, string httpForwarded)
        {
            DbAuthorizeService service = new DbAuthorizeService();
            service.LogAction(appCode, ticket, permCode, pathAndQuery, authorized, ipAddress, httpForwarded);
        }


        public string[] GetRolesByUrl(string appCode, string url)
        {
            DbAuthorizeService service = new DbAuthorizeService();
            return service.GetRolesByUrl(appCode, url);
        }


        public AppEntry[] GetAppEntries(string ticket)
        {
            DbAuthorizeService service = new DbAuthorizeService();
            return service.GetAppEntries(ticket);
        }
    }
}
